﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EZCRS.HCMS.DataAcl;

namespace EZCRS.HCMS.Bll.Report
{
    public class ReservationReport
    {
        protected static Boolean _singleton = true;
        protected static ReservationReport _instance;

        public ReservationReport()
        {
            if (_singleton)
            {
                throw new Exception("Call getInstance() function first!");
            }
        }


        public static ReservationReport getInstance()
        {
            if (_instance == null)
            {
                _singleton = false;
                _instance = new ReservationReport();
                _singleton = true;
            }

            return _instance;
        }


        private ReportData _rptdata = new ReportData();

        public int GetReserveYearAmount(int Year)
        {

            return _rptdata.GetReserveAmount(Year, string.Empty);
        }

        public int GetReserveYearAmountByChannel(int Year, string ChannelID)
        {

            return _rptdata.GetReserveAmount(Year, ChannelID);
        }

        public int GetReserveMonthAmountByChannel(int Year, int Month, string ChannelID)
        {
            return _rptdata.GetReserveMonthAmount(Year, Month, ChannelID);
        }

        /// <summary>
        /// 获取渠道某时段订单总和
        /// </summary>
        /// <param name="Year"></param>
        /// <param name="Month"></param>
        /// <param name="ChannelID"></param>
        /// <returns></returns>
        public int GetReservationCount(int Year, int Month, string ChannelID, string Status)
        {
            string strDate1 = Year.ToString() + "-" + Month.ToString() + "-1";

            if (Month >= 12)
                Month = 12;

            DateTime dt2 = Convert.ToDateTime(strDate1);

            while (dt2.Month == Month)
            {
                dt2 = dt2.AddDays(1);
            }

            DateTime dt1 = DateTime.Parse(strDate1);

            return _rptdata.GetReservationCount(dt1, dt2, ChannelID, Status);

        }

        public int GetReservationCount(int Year, int Month, string ChannelID, int Status)
        {
            string strDate1 = Year.ToString() + "-" + Month.ToString() + "-1";

            if (Month >= 12)
                Month = 12;

            DateTime dt2 = Convert.ToDateTime(strDate1);

            while (dt2.Month == Month)
            {
                dt2 = dt2.AddDays(1);
            }

            DateTime dt1 = DateTime.Parse(strDate1);

            return _rptdata.GetReservationCount(dt1, dt2, ChannelID, Status);

        }
    }
}
